package com.kgc.onlineLife.util;

import lombok.Data;

/**
 * Created On : 2022/4/16.
 * <p>
 * Author     : nainai
 * <p>
 * Description: 分页实体类
 */
@Data
public class Page {

    // 当前页码
    private Integer pageNo = 1;

    // 每页显示条数
    private Integer pageSize = 8;

    // 总条数
    private Integer totalCount = 0;

    // 总页数
    private Integer totalPage = 0;

    public void setTotalCount(Integer totalCount) {
        // 总条数确定时，确定总页数
        if (totalCount > 0){
            this.totalCount = totalCount;
            this.totalPage = (totalCount % pageSize) == 0 ? totalCount / pageSize : (totalCount / pageSize) + 1;
        }
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
        this.totalPage = (totalCount % pageSize) == 0 ? totalCount / pageSize : (totalCount / pageSize) + 1;
    }


}
